<template>
  <header class="page-header">
    <div class="header-content">
      <div class="header-main">
        <div class="title-section">
          <h1 class="page-title" :class="{ 'loading': loading }">
            <Transition name="fade" mode="out-in">
              <span v-if="!loading" key="title">{{ title }}</span>
              <span v-else key="loading" class="loading-title">加载中...</span>
            </Transition>
          </h1>
          <p class="page-description">{{ description }}</p>
        </div>
        
        <div class="header-meta">
          <div class="breadcrumb">
            <router-link to="/" class="breadcrumb-item">
              <i class="fas fa-home"></i>
              <span>首页</span>
            </router-link>
            <i class="fas fa-chevron-right breadcrumb-separator"></i>
            <span class="breadcrumb-item current">{{ title || '加载中' }}</span>
          </div>
          
          <div class="header-actions">
            <button class="header-btn" @click="$emit('refresh')" :disabled="loading">
              <i class="fas fa-sync-alt" :class="{ 'spinning': loading }"></i>
              <span>刷新</span>
            </button>
          </div>
        </div>
      </div>
      
      <div class="header-decoration">
        <div class="decoration-circle circle-1"></div>
        <div class="decoration-circle circle-2"></div>
        <div class="decoration-circle circle-3"></div>
      </div>
    </div>
    
    <div class="header-wave">
      <svg viewBox="0 0 1200 120" preserveAspectRatio="none">
        <path d="M0,80 C300,120 900,40 1200,80 L1200,120 L0,120 Z" fill="var(--bg-primary)"></path>
      </svg>
    </div>
  </header>
</template>

<script setup>
defineProps({
  title: {
    type: String,
    default: ''
  },
  description: {
    type: String,
    default: ''
  },
  loading: {
    type: Boolean,
    default: false
  }
})

defineEmits(['refresh'])
</script>

<style scoped>
.page-header {
  position: relative;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 50%, var(--color-accent) 100%);
  color: var(--text-inverse);
  padding: var(--space-2xl) 0 var(--space-3xl);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  position: relative;
  z-index: 2;
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-xl);
}

.title-section {
  flex: 1;
}

.page-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  margin: 0 0 var(--space-md);
  line-height: var(--line-height-tight);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
}

.page-title.loading {
  opacity: 0.7;
}

.loading-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.loading-title::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.page-description {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-light);
  opacity: 0.9;
  margin: 0;
  max-width: 600px;
  line-height: var(--line-height-normal);
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-md);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  opacity: 0.8;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text-inverse);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.breadcrumb-item:hover:not(.current) {
  opacity: 1;
}

.breadcrumb-item.current {
  font-weight: var(--font-weight-medium);
}

.breadcrumb-separator {
  opacity: 0.5;
  font-size: var(--font-size-xs);
}

.header-actions {
  display: flex;
  gap: var(--space-sm);
}

.header-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-inverse);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
}

.header-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.header-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.header-btn .spinning {
  animation: spin 1s linear infinite;
}

.header-decoration {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
}

.decoration-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  animation: float 6s ease-in-out infinite;
}

.circle-1 {
  width: 120px;
  height: 120px;
  top: 20%;
  right: 10%;
  animation-delay: 0s;
}

.circle-2 {
  width: 80px;
  height: 80px;
  top: 60%;
  right: 20%;
  animation-delay: 2s;
}

.circle-3 {
  width: 60px;
  height: 60px;
  top: 40%;
  right: 5%;
  animation-delay: 4s;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33% { transform: translateY(-10px) rotate(120deg); }
  66% { transform: translateY(5px) rotate(240deg); }
}

.header-wave {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 60px;
  z-index: 3;
}

.header-wave svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    padding: var(--space-xl) 0 var(--space-2xl);
  }
  
  .header-content {
    padding: 0 var(--space-md);
  }
  
  .header-main {
    flex-direction: column;
    gap: var(--space-lg);
  }
  
  .header-meta {
    align-items: flex-start;
    width: 100%;
  }
  
  .page-title {
    font-size: var(--font-size-3xl);
  }
  
  .page-description {
    font-size: var(--font-size-md);
  }
  
  .breadcrumb {
    order: 1;
  }
  
  .header-actions {
    order: 2;
    justify-content: flex-start;
  }
  
  .decoration-circle {
    display: none;
  }
}

/* 动画 */
.fade-enter-active,
.fade-leave-active {
  transition: all var(--transition-fast);
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
  transform: translateY(-10px);
}

/* 高对比度支持 */
@media (prefers-contrast: high) {
  .page-header {
    background: var(--color-primary);
  }
  
  .header-btn {
    border-color: var(--text-inverse);
  }
}

/* 减少动画支持 */
@media (prefers-reduced-motion: reduce) {
  .decoration-circle {
    animation: none;
  }
  
  .loading-title::after {
    animation: none;
  }
  
  .header-btn .spinning {
    animation: none;
  }
}
</style> 